﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace UdrinkWater_Project.Admin
{
    public partial class BillOnline : System.Web.UI.Page
    {
        private string OrderDate = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            string d = Session["Date"].ToString();
            string t = Session["Time"].ToString();
            OrderDate = d+" "+t;
            SqlDataSource1.Select(DataSourceSelectArguments.Empty);
            DataTable dt = new DataTable();
            DataTable ds = new DataTable();
            DataView dvSql = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);
            dt = dvSql.ToTable();
            if (Session["GuestEmp"].ToString() == "false" )
            {
                txtCustomer.Text = dt.Rows[0]["Customer_ID"].ToString();
                txtCustomerName.Text = dt.Rows[0]["CusName"].ToString();
            }
            if (txtCustomerName.Text == "")
            {
                Session["GuestEmp"] = "true";
            }
            if (Session["GuestEmp"].ToString() == "true" )
            {
                txtCustomer.Text = "";
                txtCustomerName.Text = dt.Rows[0]["Customer_ID"].ToString();
            }
            txtDate.Text = dt.Rows[0]["Order_Date"].ToString();
            txtShipp.Text = dt.Rows[0]["Shipped_date"].ToString();
            txtAddress.Text = dt.Rows[0]["Delivery_Address"].ToString();
            txtProvince.Text = dt.Rows[0]["PROVINCE_NAME"].ToString();
            txtDistric.Text = dt.Rows[0]["DISTRICT_NAME"].ToString();
            txtAmphur.Text = dt.Rows[0]["AMPHUR_NAME"].ToString();
            txtZipcode.Text = dt.Rows[0]["Zipcode"].ToString();
            txtEmpname.Text = dt.Rows[0]["Employee_ID"].ToString();
            txtEmpn.Text = dt.Rows[0]["EmpName"].ToString();
            Session["CusName"] = txtCustomerName.Text;
            Session["PROVINCE_NAME"] = txtProvince.Text;
            Session["DISTRICT_NAME"] = txtDistric.Text;
            Session["AMPHUR_NAME"] = txtAmphur.Text;
            Session["Zipcode"] = txtZipcode.Text;
            Session["list"] = (dt.Rows.Count).ToString();
        }

        protected void SqlDataSource1_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
        {
            e.Command.Parameters["@Order_Date"].Value = OrderDate;

        }

        protected void ASPxButton1_Click(object sender, EventArgs e)
        {
            Response.Redirect("ReportShopFront.aspx");
        }

        protected void ASPxGridView1_SummaryDisplayText(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewSummaryDisplayTextEventArgs e)
        {
            if (e.Value != null)
            {
                float to = float.Parse(e.Value.ToString());
                Session["SumAll"] = to.ToString("0.00");
            }
        }
    }
}